package com.mysoft.gfyx.clue.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mysoft.framework.service.AppService;
import com.mysoft.gfyx.clue.dao.OpptySubsCustomerDataDao;
import com.mysoft.gfyx.clue.dao.OpptySubsPurchaseDataDao;
import com.mysoft.gfyx.clue.dao.entity.OpptySubsCustomerData;
import com.mysoft.gfyx.clue.dao.entity.OpptySubsPurchaseData;
import com.mysoft.gfyx.clue.service.OpptySubsPurchaseDataService;
import com.mysoft.gfyx.clue.service.dto.PushDataStatDto;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

@Service

/**
* 描述：OpptySubsPurchaseData 业务代码
* @author JavaSdk generator
* @date 2022-07-07
*/
public class OpptySubsPurchaseDataServiceImp extends AppService implements OpptySubsPurchaseDataService {
    @Resource
    private OpptySubsPurchaseDataDao opptySubsPurchaseDataDao;


    @Override
    public boolean updatePush(UUID opptySubsGUID) {
        int r = opptySubsPurchaseDataDao.updatePush(opptySubsGUID);
        return true;
    }

    @Override
    public PushDataStatDto pushDataStat(UUID opptySubsGUID) {
        QueryWrapper<OpptySubsPurchaseData> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("OpptySubsGUID", opptySubsGUID);
        queryWrapper.eq("IsPush", 0);
        queryWrapper.last("limit 1000");
        PushDataStatDto pushDataStatDto = new PushDataStatDto();
        List<OpptySubsPurchaseData> opptySubsPurchaseDataList = opptySubsPurchaseDataDao.selectList(queryWrapper);
        //todo 统计
        for (OpptySubsPurchaseData opptySubsPurchaseData : opptySubsPurchaseDataList) {
            pushDataStatDto.setTotal(pushDataStatDto.getTotal()+1);
        }
        return pushDataStatDto;
    }
}
